package design_modle.Strategy;

import design_modle.factory.CahRebate;
import design_modle.factory.CashNomal;
import design_modle.factory.CashReturn;
import design_modle.factory.CashSuper;

public class CashContext {
    private CashSuper cashSuper;

    public CashContext(String type) {
        this.cashSuper = switch (type){
            case "正常收费" -> new CashNomal();
            case "满300返100" -> new CashReturn(300 , 100);
            case "打8折" ->new CahRebate(0.8);
            default -> throw new IllegalStateException("Unexpected value: " + type);
        };
    }

    public double getResult(double money){
        return cashSuper.acceptCash(money);
    }
}
